<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>{{ title or '首页' }}-{{ get_option('title').val or 'PyFly' }}</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="keywords" content="{{ get_option('keywords').val }}">
  <meta name="description" content="{{ get_option('description').val }}">
  <link rel="stylesheet" href="/static/layui/css/layui.css">
  <link rel="stylesheet" href="/static/css/global.css">
  {% block other_res %}
  {% endblock %}
</head>
<body>

<div class="fly-header layui-bg-black">
  <div class="layui-container">
    <a class="fly-logo" href="/">
      <img src="{{ get_option('logo').val or '/static/images/logo.png' }}" alt="layui">
    </a>
    <ul class="layui-nav fly-nav layui-hide-xs">
      {% for item in get_list('pages', sort_by=('sort', -1)) %}
        <li class="layui-nav-item layui-this">
          <a href="{{ item.url }}">{{ item.name }} <i class="layui-icon">{{ item.icon_code|safe }}</i>  </a>
        </li>
      {% endfor %}
    </ul>

    <ul class="layui-nav fly-nav-user">

      {% if current_user.is_authenticated %}

        <li class="layui-nav-item">
          <a class="fly-nav-avatar" href="javascript:;">

            <cite class="layui-hide-xs">{{ current_user.user.username }}</cite>
            {% if current_user.user.renzheng %}
              <i class="iconfont icon-renzheng" title="{{ current_user.user.renzheng }}"></i>
            {% endif %}
            {% if current_user.user.get('vip', 0) > 0 %}
              <i class="layui-badge fly-badge-vip">VIP{{ current_user.user.vip }}</i>
            {% endif %}
            <img src="{{ current_user.user.avatar }}">
          </a>
          <dl class="layui-nav-child">
            <dd><a href="{{ url_for('user.user_set') }}"><i class="layui-icon">&#xe620;</i>基本设置</a></dd>
            <dd><a href="{{ url_for('user.user_message') }}"><i class="iconfont icon-tongzhi" style="top: 4px;"></i>我的消息</a></dd>
            <dd><a href="{{ url_for('user.user_home', user_id=current_user.user._id) }}"><i class="layui-icon" style="margin-left: 2px; font-size: 22px;">&#xe68e;</i>我的主页</a>
            </dd>
            <hr style="margin: 5px 0;">
            <dd><a href="{{ url_for('user.logout') }}" style="text-align: center;">退出</a></dd>
          </dl>
        </li>
        {% if current_user.user.get('unread', 0) > 0 %}
          <li class="layui-nav-item">
          <a href="{{ url_for('user.user_message') }}"><span class="layui-badge">{{ current_user.user.unread }}</span></a>
        </li>
        {% endif %}
      {% else %}
        {% if get_option('open_user').val == '1' %}
          <li class="layui-nav-item">
            <a class="iconfont icon-touxiang layui-hide-xs" href="{{ url_for('user.login') }}"></a>
          </li>
          <li class="layui-nav-item">
            <a href="{{ url_for('user.login') }}">登入</a>
          </li>
          <li class="layui-nav-item">
            <a href="{{ url_for('user.register') }}">注册</a>
          </li>
          {#        <li class="layui-nav-item layui-hide-xs">#}
          {#          <a href="/app/qq/" onclick="layer.msg('正在通过QQ登入', {icon:16, shade: 0.1, time:0})" title="QQ登入"#}
          {#             class="iconfont icon-qq"></a>#}
          {#        </li>#}
          {#        <li class="layui-nav-item layui-hide-xs">#}
          {#          <a href="/app/weibo/" onclick="layer.msg('正在通过微博登入', {icon:16, shade: 0.1, time:0})" title="微博登入"#}
          {#             class="iconfont icon-weibo"></a>#}
          {#        </li>#}
        {% endif %}
      {% endif %}
    </ul>
  </div>
</div>
{% block body %}

{% endblock %}


<div class="fly-footer">
  <p>{{ get_option('footer').val|safe or 'Power by PyFly' }}</p>
  <p>
    {% for item in get_list('footer_links', sort_by=('sort', -1)) %}
      <a href="{{ item.url }}" target="_blank">{{ item.name }}</a>
    {% endfor %}
  </p>
</div>

<script src="/static/layui/layui.js"></script>

<script>
    layui.cache.page = '{{ page_name if page_name else '' }}';
    layui.cache.user = {
        username: '{{ current_user.user['username'] if current_user.is_authenticated else '游客'}}'
        , uid: '{{ current_user.user['_id'] if current_user.is_authenticated }}'
        , avatar: '{{ current_user.user['avatar'] if current_user.is_authenticated}}'
        , experience: '{{ current_user.user['coin'] if current_user.is_authenticated else '0'}}'
        , sex: '{{ current_user.user.get('sex', '未知') if current_user.is_authenticated else '未知'}}'
    };
    layui.config({
        version: "3.0.0"
        , base: '/static/mods/' //这里实际使用时，建议改成绝对路径
    }).extend({
        fly: 'index'
    }){% block fly_use %}.use('fly');{% endblock %}
</script>

{% block other_js %}
{% endblock %}

</body>
</html>